from PIL import Image
from os.path import isfile, splitext
img_path = "uuus.jpg"

img = Image.open(img_path)          # 打开图片文件
icon_sizes = [(100, 100)]             # 定义图标大小
base_name = splitext(img_path)[0]   # 提取图像文件基本名称（不包括扩展名）
icon_filename = f"{base_name}.ico"
img.save(icon_filename, sizes=icon_sizes)
print(f"图标文件已保存为: {icon_filename}")
 
 